#include<stdio.h>
#include<unistd.h>
#include<string.h>
int main(){
    int fd[2];
    int ret = pipe(fd);
    if(ret < 0){
        perror("pipe");
        return 0;
    }
    ssize_t write_size = 0;
    pid_t pid = fork();
    if(pid < 0){
        perror("fork");
        return 0;
    }else if(pid == 0){
        //child,写数据
        const char* buf = "linux is so easy\n";
        write_size = write(fd[1],buf,strlen(buf));
        printf("write_size = %ld\n",write_size);
    }else{
        //father，读数据
        char buf[1024] = {0};
        ssize_t read_size = read(fd[0],buf,sizeof(buf) - 1);
        printf("read_size = %ld，%s\n",read_size,buf);
        printf("write_size = %ld\n",write_size);
    }
    while(1){

    }
    return 0;
}
